<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>js动态时间显示 </title>
</head>
 
<body id = "showtime">
  
<script>
  
  
 	function disptime(){
        var time = new Date();//获取系统当前时间
 		var year = time.getFullYear();
 		var month = time.getMonth()+1;
 		var date= time.getDate();//系统时间月份中的日
 		var day = time.getDay();
 		var weeks = ["星期日","星期一","星期二","星期三","星期四","星期五","星期六"];
 		var week = weeks[day];//显示为星期几
 		var hour = time.getHours();
 		var minutes = time.getMinutes();
 		var seconds = time.getSeconds();
		//	主要为了美观，对称
 		if(month<10){
 			month = "0"+month; 
 		}
 		if(date<10){
 			date = "0"+date; 
 		}
 		if(hour<10){
 			hour = "0"+hour; 
 		}
 		if(minutes<10){
 			minutes = "0"+minutes; 
 		}
 		if(seconds<10){
 			seconds = "0"+seconds; 
 		}
 
 		document.getElementById("showtime").innerHTML = year+"年"+month+"月"+date+"日"+week+hour+":"+minutes+":"+seconds;
 		setTimeout('disptime()',1000);//1000毫秒等待的时间
 		}
  
 	disptime();
 
  
  
</script>
</body>
</html>